using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Reflection;

namespace NETCheck
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			if (HasNET35())
			{
				try
				{
					Process.Start("ViewOn.exe");
				}
				catch (Exception e)
				{
					Console.WriteLine(e.Message);
				}
			}
			else
			{
				Application.EnableVisualStyles();
				Application.SetCompatibleTextRenderingDefault(false);
				Application.Run(new NoWPFForm());
			}
		}

		static private bool HasNET35()
		{
			if (System.Environment.Version.Major < 2)
				return false;

			//---- Check for WPF 3.5 minimum
			try
			{
				Assembly net35dll = System.Reflection.Assembly.LoadWithPartialName("System.Windows.Presentation"); // "PresentationFramework"

				Version version = net35dll.GetName().Version;
				if (version.Major < 3)
					return false;
				if (version.Minor < 5)
					return false;
			}
			catch
			{
				return false;
			}

			return true;
		}
	}
}